'use strict';

// note: controller with same name is used in 'list bank cards' (bank-card-list.js)
angular.module('wdApp', [])
.controller('bankCardController', bankCardController);

function bankCardController($scope) {
    var phone_no_pattern = /^1\d{10}$/; //电话号码格式
    
    
    $scope._phoneNoTest = true;
    $scope._showPhoneNoError = true;
    $scope.phoneNoErrorText = "请输入手机号";
    
    // 输入电话号码时
    $scope.wng_phone_no_change = function() {
        // 测试电话号码格式
        $scope._phoneNoTest = phone_no_pattern.test($scope.phoneNo);
        
        // 决定显示逻辑
        if ($scope._phoneNoTest) {
            $scope.phoneNoErrorText = ""; //清除错误信息
            debug_log('passed');
        }else{
            if ($scope.phoneNo.length > 0) {
                $scope.phoneNoErrorText = "手机号不正确";
            }else{
                $scope.phoneNoErrorText = "请输入手机号";
            }
            debug_log('not good');
        }
    };
    $scope.wng_card_no_change = function() {
      debug_log('x');  
    };
} //END-OF: function bankCardController($scope)

/*
 * 页面逻辑
 * 
 */
/*
var phoneNoPattern = /^1\d{10}$/;
var WAIT_INTERVAL = 60;
var wait = WAIT_INTERVAL;
var vcTimeout = null;
var inputLength = 0;
var support_bank = ["工商银行", "农业银行", "中国银行", "建设银行", "光大银行", "广发银行", "民生银行", "中信银行", "平安银行"];

function onPhoneNoChanged() {
    var ret = verifyInput();
    var isPhoneValid = ret[0];

    if (wait == WAIT_INTERVAL) {
        $(".verify-code").prop("disabled", !isPhoneValid);
        var phone = $('#phoneNo').val();
        if (phone.length < 11 || isPhoneValid) {
            $("#checkPhoneNo").hide();
        } else {
            $("#checkPhoneNo").show();
        }
    }
}
*/